package admin_role_menus

import (
	"gitee.com/theegg/go-brick/app/service/app"
)

// 获取 角色的 menu Ids
// @param roleId int64
// @return []int64 error
func GetMenuIdsByRoleId(roleId int64) ([]int64, error) {
	roleMenus, err := GetAllAdminRoleMenusFromCache()
	if err != nil {
		return nil, app.NewError(err)
	}

	returnData := make([]int64, 0)
	for _, item := range roleMenus {
		if item.RoleId == roleId {
			returnData = append(returnData, item.MenuId)
		}
	}

	return returnData, nil
}
